package com.formula.datastructure.exam.tree;

public class HuffmanNode {
    public Integer weight;
    public String data;
    public String code;
    public HuffmanNode left;
    public HuffmanNode right;
    public HuffmanNode parent;

    public HuffmanNode() {
    }

    public HuffmanNode(Integer weight) {
        this.weight = weight;
    }

    public void genCode(String theCode) {
        if(left == null && right == null){
            code = theCode;
        }
        if (left != null) {
            left.genCode('0' + theCode);
        }
        if (right != null) {
            right.genCode('1' + theCode);
        }
    }
}
